package com.COMP3111H.project;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class BuyBorrow_Success_Page extends Activity {
	/** Called when the activity is first created. */
	TextView tittle, content;
	final int HELP = 0;
	Button menu;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.buyborrow_success_page);
		
		Button home = (Button)findViewById(R.id.bHome);
		home.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				Intent i = new Intent(BuyBorrow_Success_Page.this, Home.class);
				startActivity(i);
			}
		});

		// initializer();
		menu = (Button) findViewById(R.id.buyborrow_sucess_menu);
	}
	
	@Override
    protected void onResume() {
		super.onResume();
		if (LoginUtility.checkLoginStatus(this)) {
			menu.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					 String[] choices={"Home","View My Profile","Help","Cancel"};  
					             AlertDialog dialog = new AlertDialog.Builder(BuyBorrow_Success_Page.this)  
					                     // .setIcon(android.R.drawable.btn_star)  
					                      .setTitle("Menu")  
					                      .setItems(choices, onselect_logged).create();  
					             dialog.show();  
				}
			});
		}
		else{
			menu.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					 String[] choices={"Home","Help","Cancel"};  
					             AlertDialog dialog = new AlertDialog.Builder(BuyBorrow_Success_Page.this)  
					                     // .setIcon(android.R.drawable.btn_star)  
					                      .setTitle("Menu")  
					                      .setItems(choices, onselect_not_logged).create();  
					             dialog.show();  
				}
			});
		}
	}

	OnClickListener onselect_logged = new OnClickListener() {
		public void onClick(DialogInterface dialog, int which) {
			// TODO Auto-generated method stub
			Intent myIntent;
			switch (which) {
			case 0:
				myIntent = new Intent(BuyBorrow_Success_Page.this, Home.class);
				startActivity(myIntent);
				break;
			case 1:
				myIntent = new Intent(BuyBorrow_Success_Page.this, My_Profile.class);
				startActivity(myIntent);
				break;
			case 2:
				myIntent = new Intent(BuyBorrow_Success_Page.this, Help.class);
				startActivity(myIntent);
				break;
			case 3:
				dialog.dismiss();
				break;
			}
		}
	};
	
	OnClickListener onselect_not_logged = new OnClickListener() {
		public void onClick(DialogInterface dialog, int which) {
			// TODO Auto-generated method stub
			Intent myIntent;
			switch (which) {
			case 0:
				myIntent = new Intent(BuyBorrow_Success_Page.this, Home.class);
				startActivity(myIntent);
				break;
			case 1:
				myIntent = new Intent(BuyBorrow_Success_Page.this, Help.class);
				startActivity(myIntent);
				break;
			case 2:
				dialog.dismiss();
				break;
			}
		}
	};

	private void initializer() {
		// TODO Auto-generated method stub
		// Set the background to be white
		this.getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
		//
		(tittle = (TextView) findViewById(R.id.tvTitle))
				.setTextColor(Color.BLACK);

		(content = (TextView) findViewById(R.id.tvContent))
				.setTextColor(Color.BLACK);

	}
	
	@Override
	public void onBackPressed() {
	   return;
	}

}